package src.thread;

public class SleepDemo2 {
        public static void main(String[] args) {
                Thread jun=new Thread("君jun"){
                        public void run(){
                                System.out.println(getName()+"下课了回宿舍睡会儿");
                                try {
                                        Thread.sleep(500000);
                                } catch (InterruptedException e) {
                                        System.out.println("干嘛呢，还让不让睡了");
                                }
                                System.out.println("吵醒了");
                        }
                };
                Thread xin=new Thread("little"){
                        public void run(){
                                System.out.println(getName()+"下课了出去玩");
                                for (int i = 0; i < 5; i++) {
                                        System.out.println(getName()+",hahahahahha");
                                try {
                                        Thread.sleep(1000);
                                } catch (InterruptedException e) {
                                }
                            }
                                System.out.println("好啊好啊好啊！");
                                System.out.println("那咱们出去玩！！");
                                jun.interrupt();//xin线程去中断jun线程的睡眠阻塞
                        }
                };
                jun.start();
                xin.start();

        }
}
